<script>
  function aaa(name,definition){
      $('#itemname').val(name);
      $('#definition').html(definition);
    }
</script>

<ul class="breadcrumb">
  <li><a href="{:U(GROUP_NAME . '/Index/index')}">首页</a> <span class="divider">/</span></li>
  <li class="active">词条管理</li>
</ul>
<h2 class="text-center">词条列表</h2>
<table class="table">
        <thead>
            <tr>
                <td>词条ID</td>
                <td>词条名称</td> 
                <td>所属文献</td> 
                <td>时间</td> 
                <td>编辑词条</td>
                <td>删除词条</td>
            </tr>                           
        </thead>
        <tbody>
            <volist name="item" id="u">
              <tr>
                <td>{$u.i_id}</td>
                <td class="item_name">{$u.itemname}</td>
                <td class="definition">
                  <a href="{:U(GROUP_NAME . '/Person/work_platform', array('d_id' => $u['Document']['d_id']))}">{$u.Document.docname}</a>
                </td>
                <td>{$u.createtime}</td>
                <td>
                  <a href="#myModal" data-toggle="modal"><i onclick="aaa('{$u.Document.docname}','{$u.definition}')" class="icon-edit tomodal"></i>
                </a>
                </td>
                <td>
                  <a href="{:U(GROUP_NAME . '/Person/deleteItemHandle', array('i_id' => $u['i_id']))}" onclick="return confirm('确定将此文献删除?')"><i class="icon-remove"></i></a>
                </td>
              </tr>
            </volist>
        </tbody>
</table>
<div class="pagination pagination-centered">
    <ul>
        <label>当前&nbsp;{$page.nowPage}&nbsp;页/共&nbsp;{$page.totalPages}&nbsp;页</label>
        <li><a href="__ACTION__/p/{$page.firstPage}">第一页</a></li>
        <li><a href="__ACTION__/p/{$page.prePage}">上一页</a></li>
        <li><a href="__ACTION__/p/{$page.nextPage}">下一页</a></li>
        <li><a href="__ACTION__/p/{$page.totalPages}">最后一页</a></li>
    </ul>
</div>

<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="myModalLabel">编辑词条</h3>
  </div>
  <div class="modal-body">
    <form class="form-horizontal" id="updateItemForm" method="post" action="{:U(GROUP_NAME . '/Person/updateItemHandle')}">
      <div class="control-group">
        <label class="control-label" for="itemname">词条名称</label>
        <div class="controls">
          <input type="text" id="itemname" name="itemname" placeholder="词条名称">
        </div>
      </div>
      <div class="control-group">
        <label class="control-label">词条定义</label>
        <div class="controls">
            <textarea name="definition" id="definition" cols="30" rows="6"></textarea>
        </div>
      </div>
    </form>
  </div>
  <div class="modal-footer">
    <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
    <button class="btn btn-primary">保存更改</button>
  </div>
</div>

<include file='Public:footer/'>

<script>
  $(function(){
    // var a_to_modal=$('.tomodal');
    // a_to_modal.each(function(){
    //   var _this=$(this)
    //   _this.click(function(){
    //     $('#itemname').val($('#'+_this.attr('index')+'tr').find('.item_name').eq(0).html());
    //     $('#definition').html($('#'+$(this).attr('index')+'tr').find('.definition').eq(0).html());
    //   })
    // })
    
  })
</script>